package com.marketing.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.marketing.dao.AdvertiseMapper;
import com.marketing.service.AdvertiseService;
import com.nameless.entity.Advertise;
import com.nameless.vo.AdvertiseVo;
import com.nameless.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author WHZ
 * @date 2023年02月28日 17:12
 */
@Service
public class AdvertiseServiceImpl extends ServiceImpl<AdvertiseMapper, Advertise> implements AdvertiseService {
    @Autowired
    private AdvertiseMapper advertiseMapper;

    @Override
    public Result findAll(AdvertiseVo advertiseVo) {
        PageHelper.startPage(advertiseVo.getPageNum(),advertiseVo.getPageSize());
        List<Advertise> all = advertiseMapper.findAll(advertiseVo);
        PageInfo<Advertise> objectPageInfo = new PageInfo<>(all);
        return new Result(200,"查询成功",objectPageInfo);
    }

    @Override
    public Result add(Advertise advertise) {
        int insert = advertiseMapper.insert(advertise);
        return new Result(200,"查询成功",insert);
    }

    @Override
    public Result del(Integer id) {
        int delete = advertiseMapper.deleteById(id);
        return new Result(200,"删除成功",delete);
    }

    @Override
    public Result put(Advertise advertise) {
        int i = advertiseMapper.updateById(advertise);
        return new Result(200,"修改成功",i);
    }
}
